package com.bbzn.device.client.service;

import com.aliyun.tea.*;
import com.aliyun.facebody20191230.*;
import com.aliyun.facebody20191230.models.*;
import com.aliyun.teaopenapi.models.Config;
//import com.aliyuncs.CommonRequest;
//import com.aliyuncs.CommonResponse;
//import com.aliyuncs.DefaultAcsClient;
//import com.aliyuncs.IAcsClient;
//import com.aliyuncs.exceptions.ClientException;
//import com.aliyuncs.exceptions.ServerException;
//import com.aliyuncs.http.MethodType;
//import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.CommonRequest;
import com.aliyuncs.CommonResponse;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.IAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author wulongbo
 * @Date 2022/1/12 10:31
 * @Version 1.0
 */
public class DetectLivingFace {

//    /**
//     *  使用AK&SK初始化账号Client
//     * @param accessKeyId
//     * @param accessKeySecret
//     * @return
//     * @throws Exception
//     */
//    public static com.aliyun.facebody20191230.Client createClient(String accessKeyId, String accessKeySecret) throws Exception {
//        Config config = new Config()
//                // 您的AccessKey ID
//                .setAccessKeyId(accessKeyId)
//                // 您的AccessKey Secret
//                .setAccessKeySecret(accessKeySecret);
//        // 访问的域名
//        config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
//        return new com.aliyun.facebody20191230.Client(config);
//    }
//
//    public static void main(String[] args_) throws Exception {
//        java.util.List<String> args = java.util.Arrays.asList(args_);
//        com.aliyun.facebody20191230.Client client = DetectLivingFace.createClient("LTAI4Ftwf8wSXy9jZKr6G6CA", "0borTfaLj14KpFFW4M4eyF7cqbjBsq");
//        DetectLivingFaceRequest detectLivingFaceRequest = new DetectLivingFaceRequest();
//        List<DetectLivingFaceRequest.DetectLivingFaceRequestTasks> list = new ArrayList<>();
//        DetectLivingFaceRequest.DetectLivingFaceRequestTasks tasks = new DetectLivingFaceRequest.DetectLivingFaceRequestTasks();
//        tasks.setImageURL("https://baba-face.oss-cn-shanghai.aliyuncs.com/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20220111143605.jpg?Expires=1641954754&OSSAccessKeyId=TMP.3KkcWRufBAa5p7wRMyi6pQN9Gf329Rve8eVHQpUnbn7f5pKFsbWvSGxr9yf4qLyrMaB4sMEDp265KF69jicKPeiffdfb31&Signature=I6S%2B8oKhQD7YMncGW83sOV7GYRc%3D");
//        list.add(tasks);
//        detectLivingFaceRequest.setTasks(list);
//        client.detectLivingFace(detectLivingFaceRequest);
//    }

    public static void main(String[] args) {
        DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "LTAI4Ftwf8wSXy9jZKr6G6CA", "0borTfaLj14KpFFW4M4eyF7cqbjBsq");
        /** use STS Token
         DefaultProfile profile = DefaultProfile.getProfile(
         "<your-region-id>",           // The region ID
         "<your-access-key-id>",       // The AccessKey ID of the RAM account
         "<your-access-key-secret>",   // The AccessKey Secret of the RAM account
         "<your-sts-token>");          // STS Token
         **/
        IAcsClient client = new DefaultAcsClient(profile);
        CommonRequest request = new CommonRequest();
        request.setSysMethod(MethodType.POST);
        request.setSysDomain("facebody.cn-shanghai.aliyuncs.com");
        request.setSysVersion("2019-12-30");
        request.setSysAction("DetectLivingFace");
        request.putQueryParameter("Tasks.1.ImageURL", "https://baba-face.oss-cn-shanghai.aliyuncs.com/wulongbo.jpg");
        try {
            CommonResponse response = client.getCommonResponse(request);
            System.out.println(response.getData());
        } catch (ServerException e) {
            e.printStackTrace();
        } catch (ClientException e) {
            e.printStackTrace();
        }
    }
}
